package com.yhl.log.service.impl;

import com.yhl.log.entity.GoodsBill;
import com.yhl.log.mapper.GoodsBillMapper;
import com.yhl.log.service.GoodsBillService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
* @author YaoHongli
* @since 2023-08-07 16:31:26
*/
@Slf4j
@Service
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class GoodsBillServiceImpl implements GoodsBillService {
    @Autowired
    private GoodsBillMapper goodsBillMapper;

    @Override
    public void addGoodsBill(GoodsBill goodsBill){
//        goodsBill.setGoods(new JSONObject()); // 设置 goods 字段为空 JSON 对象
//        goodsBill.setUserMessage(new JSONObject()); // 设置 userMessage 字段为空 JSON 对象
        goodsBill.setPurchaseTime(new Date());
        goodsBillMapper.addGoodsBill(goodsBill);
    }
    @Override
    public void deleteGoodsBill(String id){
        goodsBillMapper.deleteGoodsBill(id);
    }
//    @Override
//    public void updateGoodsBill(GoodsBill goodsBill){
//        goodsBillMapper.updateGoodsBill(goodsBill);
//    }
//    @Override
//    public GoodsBill getGoodsBillById(String id){
//        return goodsBillMapper.getGoodsBillById(id);
//    }

    @Override
    public List<GoodsBill> getGoodsList() {
        return goodsBillMapper.getGoodsList();
    }
}

